import request from './request'

// export const getProductList = ()=> request.get('/goods/selectAll')
export function getProductList(page = 1, pagesize = 50 ){
  return request({
      url: '/goods/getAllGoods',
      params:{
          page,
          pagesize
      }
  })
}

export const goLogin = data=> request.post('/login/userLogin',data)

export function selectUserByToken(token) {
  return request({
    headers: {'Authorization': token},
    url: '/user/selectUserByToken',
    method: 'get'
  })
}

export const register = data => request.post('/user/register',data)

export const getCategoryList = ()=> request.get('/category/selectAll')

export const getCategoryGoodsList = params =>request.get('/category/selectGoodsByCategoryId',{params})

export const search = data => request.post('/goods/search',data)

export const getUserAccount = params => request.get('/user/getUserAccount',{params})

export const recharge = params => request.get('/user/recharge',{params})

export const collect = data => request.post('/collect/collect',data)

export const cancelCollect = data => request.post('/collect/cancelCollect',data)

export const selectAllCollectGoods = params => request.get('/collect/selectAll',{params})

export const deleteSelect = data => request.post('/collect/deleteSelect',data)

// export const getProductById = params => request.get('/goods/selectById',{params})
export function getProductById(id){
  return request({
      url: '/goods/getGoodsDetail?id=' + id,
  })
}

export const firstAddCollect = data => request.post('/cart/insert',data)

export const selectAllUserIdInCart = ()=> request.get('/cart/selectAllUserIdInCart')

export const addUpdate = data => request.post('/cart/addUpdate',data)

export const selectGoodsByCart = params => request.get('/cart/selectGoodsByCart',{params})

export const addAddress = data => request.post('/address/insert',data)

export const getAddressList = params => request.get('/address/selectAll',{params})

export const delAddress = params => request.get('/address/delete',{params})

export const addOrder = data => request.post('/order/insert',data)

export const pay = data => request.post('/order/pay',data)

export const getStatusData = data => request.post('/order/selectByStatus',data)

export const selectAllGoodsByGoodsId = data => request.post('/goods/selectAllGoodsByGoodsId',data)

export function updateOrderStatus(id){
  return request({
    url:'/order/updateOrderStatus?id=' + id
  })
}

export function selectUserBaseInfoById(id){
  return request({
    url:'user/selectUserBaseInfoById?id=' + id,
  })
}

export const subComment = data => request.post('/comment/insert',data)

export function selectCommentByGoodsId(id){
  return request({
    url:'/comment/selectCommentByGoodsId?goodsId=' + id
  })
}

export const updateUserInfo = data =>  request.post('/user/updateUserInfo',data)

export function updateUserAvatar(file,id){
  return request({
    url:'/user/updateUserAvatar',
    method:'post',
    data:{
      file,id
    }
  })
}
